package com.qianying.controller.admin;

import com.qianying.comment.CommonResult;
import com.qianying.entity.OrderResponseTime;
import com.qianying.service.OrderResponseTimeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/orderResponseTime")
@Tag(name = "平台:订单响应时间管理")
public class OrderResponseTimeController {

    @Resource
    private OrderResponseTimeService orderResponseTimeService;

    @PostMapping("/add")
    @Operation(summary = "新增订单响应时间记录",
            parameters = {
                    @Parameter(name = "id", description = "主键ID，自增（添加的时候不需要）", example = "1"),
                    @Parameter(name = "nodeName", description = "节点名称，标识订单处理的具体环节", example = "接单节点"),
                    @Parameter(name = "expeditedOrder", description = "加急订单的响应时间（单位：分钟）", example = "30"),
                    @Parameter(name = "normalOrder", description = "普通订单的响应时间（单位：分钟）", example = "60"),
                    @Parameter(name = "customerId", description = "客户ID，关联对应的客户信息", example = "1001"),
                    @Parameter(name = "createTime", description = "记录创建时间", example = "2025-08-02 10:30:00")
            })
    public CommonResult<?> add(@RequestBody OrderResponseTime responseTime) {
        return orderResponseTimeService.insert(responseTime);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除订单响应时间记录")
    public CommonResult<?> delete(@PathVariable Long id) {
        return orderResponseTimeService.deleteByPrimaryKey(id);
    }

    @PutMapping("/update")
    @Operation(summary = "更新订单响应时间记录")
    public CommonResult<?> update(@RequestBody OrderResponseTime responseTime) {
        return orderResponseTimeService.updateByPrimaryKey(responseTime);
    }

    @GetMapping("/get")
    @Operation(summary = "获取单个订单响应时间记录")
    public CommonResult<?> get(@PathVariable Integer id) {
        return orderResponseTimeService.selectByPrimaryKey(id);
    }

    @GetMapping("/listByCustomerId")
    @Operation(summary = "按客户ID查询订单响应时间列表")
    public CommonResult<?> listByCustomerId(@PathVariable Long customerId) {
        return orderResponseTimeService.selectAllByCustomId(customerId);
    }
}